﻿<%@ Page Title="Cungmuanao.com - Quản Lý Đơn Hàng" Language="C#" MasterPageFile="~/Admin/Admin.master" AutoEventWireup="true" CodeFile="ManageOrders.aspx.cs" Inherits="ManageOrders" %>
<asp:Content ID="Content1" ContentPlaceHolderID="LeftContent" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server">
    <div class="title">Quản Lý Đơn Hàng</div>
   <div class="body">
<asp:UpdatePanel runat="server" ID="UpdatePanel1">
<ContentTemplate>
<asp:Label runat="server" ID="lbldepartments" Text="Chọn trạng thái : " />
    <asp:DropDownList runat="server" ID="ddlStatus" AutoPostBack="true" Width="200px">
        <asp:ListItem Text="Tất cả" Value="0"></asp:ListItem>
        <asp:ListItem Text="Đơn hàng mới" Value="1" Selected="True"></asp:ListItem>
        <asp:ListItem Text="Đơn hàng đã thanh toán" Value="2"></asp:ListItem>
        <asp:ListItem Text="Đơn hàng hủy" Value="3"></asp:ListItem>
    </asp:DropDownList>
    <asp:GridView runat="server" ID="gvwOrders" Width="100%"
        AutoGenerateColumns="False" DataSourceID="objAllOrders" DataKeyNames="ID" 
           AllowPaging="True" EnableModelValidation="True" >
    <Columns >
         <asp:TemplateField HeaderText="STT" >
            <ItemStyle HorizontalAlign="Center" Width="20" />
            <ItemTemplate>
                <asp:Literal runat="server" ID="lblSTT" Text='<%#Container.DataItemIndex + 1 %>' />
            </ItemTemplate>
        </asp:TemplateField>
        
        <asp:TemplateField HeaderText="">
            <ItemTemplate>
                <asp:Image runat="server" ID="imglogo" ImageUrl='<% # "~" + Eval("SmallImageUrl") %>' Width="50px" />
            </ItemTemplate>
        </asp:TemplateField>

        <asp:TemplateField HeaderText="Sản phẩm">
            <ItemTemplate>
                <asp:Literal runat="server" ID="lblTitle" Text='<%#Eval("ProductTitle")  %>'  />
            </ItemTemplate>
        </asp:TemplateField>

        <asp:TemplateField HeaderText="Giá">
            <ItemTemplate>
                <asp:Literal runat="server" ID="lblGia" Text='<%#Eval("Price")  %>'  />
            </ItemTemplate>
        </asp:TemplateField>

        <asp:TemplateField HeaderText="Số lượng">
            <ItemTemplate>
                <asp:Literal runat="server" ID="lblSL" Text='<%#Eval("ShippingNumber")  %>'  />
            </ItemTemplate>
        </asp:TemplateField>

        <asp:TemplateField HeaderText="Thành tiền">
            <ItemTemplate>
                <asp:Literal runat="server" ID="lblSubTotal" Text='<%#Eval("StringSubTotal")  %>'  />
            </ItemTemplate>
        </asp:TemplateField>

        <asp:TemplateField HeaderText="Họ tên">
            <ItemTemplate>
                <asp:Literal runat="server" ID="lblShippingFirstName" Text='<%#Eval("ShippingFirstName")  %>'  />
            </ItemTemplate>
        </asp:TemplateField>

        <asp:TemplateField HeaderText="Điện thoại">
            <ItemTemplate>
                <asp:Literal runat="server" ID="lblPhone" Text='<%#Eval("customerPhone")  %>'  />
            </ItemTemplate>
        </asp:TemplateField>

        <asp:TemplateField HeaderText="Email">
            <ItemTemplate>
                <asp:Literal runat="server" ID="lblEmail" Text='<%#Eval("customerEmail")  %>'  />
            </ItemTemplate>
        </asp:TemplateField>
        
        <asp:TemplateField HeaderText="Edit" ItemStyle-HorizontalAlign="Center" ItemStyle-Width="20px">
                <ItemTemplate>
                    <asp:HyperLink runat="server" ID="lnkEdit" ToolTip="Edit product"
                        NavigateUrl='<%# "~/Admin/AddEditOrder.aspx?ID=" + Eval("ID") %>' ImageUrl="~/Images/Edit.gif" />
                </ItemTemplate>         
        </asp:TemplateField>

        <asp:TemplateField HeaderText="Delete" ItemStyle-HorizontalAlign="Center" ItemStyle-Width="30px">
                <ItemTemplate>
                    <asp:ImageButton runat="server" ID="ImageButton1" ImageUrl="~/Images/Delete.gif"
                    CommandName="Delete" AlternateText="Xóa"
                    OnClientClick="if (confirm('Bạn có chắc muốn xóa đơn hàng này ?') == false) return false;" />
                </ItemTemplate>         
        </asp:TemplateField>
    </Columns>
 </asp:GridView>
</ContentTemplate>             
</asp:UpdatePanel>
    <asp:ObjectDataSource ID="objAllOrders" runat="server"
        DeleteMethod="DeleteOrder" SelectMethod="GetOrdersByStatus" 
        TypeName="BLL.Store.Order">
        <DeleteParameters>
            <asp:Parameter Name="id" Type="Int32" />
        </DeleteParameters>
        <SelectParameters>
            <asp:ControlParameter ControlID="ddlStatus" Name="statusID" 
                PropertyName="SelectedValue" Type="Int32" DefaultValue="0" />
        </SelectParameters>
    </asp:ObjectDataSource>     
    </div>
    <div class="bottom"></div>
</asp:Content>

